# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=libfido2
pkgver=1.10.0
pkgrel=1
pkgdesc="library for FIDO 2.0 functionality"
url="https://github.com/Yubico/libfido2"
arch="all"
license="BSD-2-Clause"
install="$pkgname.pre-install"
makedepends="cmake libcbor-dev openssl-dev zlib-dev eudev-dev linux-headers samurai"
subpackages="$pkgname-dev $pkgname-doc fido2:fido"
source="$pkgname-$pkgver.tar.gz::https://github.com/Yubico/libfido2/archive/refs/tags/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 -t "$pkgdir"/lib/udev/rules.d/ "$builddir"/udev/70-u2f.rules
}

fido() {
	pkgdesc="commandline utilities for FIDO 2.0"
	amove usr/bin
}

sha512sums="
ba03e25d3f42f11cec74dee48c853ae35d03600f24ca06d2b751840408a132290fe22461372ae42ae31419061a63d9908c20a2c0cf3c0c9c8dbc46c34916784f  libfido2-1.10.0.tar.gz
"
